home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UViewServer.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  5.7 KB  |  157 lines  |  [TEXT/MPS ]

  1. // UViewServer.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UVIEWSERVER__
  5. #define __UVIEWSERVER__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __UGEOMETRY__
  10. #include "UGeometry.h"
  11. #endif
  12.  
  13. #ifndef __UOBJECT__
  14. #include "UObject.h"
  15. #endif
  16.  
  17. // Toolbox
  18.  
  19.  
  20. //----------------------------------------------------------------------------------------
  21. // Forward and external class declarations. 
  22. //----------------------------------------------------------------------------------------
  23.  
  24. class TDocument;
  25. class TView;
  26. class TWindow;
  27.  
  28.  
  29. //----------------------------------------------------------------------------------------
  30. // arguments of NewPaletteWindow
  31. const VHSelect kLeftPalette = hSel;
  32. const VHSelect kTopPalette = vSel;    
  33.  
  34. //----------------------------------------------------------------------------------------
  35. // template version for MacApp 3.0 views
  36. const short kMAThreeOhTemplateVersion = 0x0300;
  37.  
  38. // --------------------------------------------------------------------------------------------------
  39. // TViewServer is responsible for creating views, either procedurally or from templates.
  40. //----------------------------------------------------------------------------------------
  41.  
  42. class TViewServer : public TObject
  43. {
  44.     MA_DECLARE_CLASS;
  45.     
  46. public:
  47.  
  48.     //------------------------------------------------------------------------------------
  49.     // Initializer, I<Method> and Free.
  50.     //------------------------------------------------------------------------------------
  51.  
  52.     TViewServer();
  53.         // Empty constructor to satisfy compiler.
  54.         
  55.     void IViewServer();
  56.         // Initializes the TViewServer. 
  57.  
  58.     virtual ~TViewServer();
  59.         // Sets the global gViewServer to NULL. 
  60.  
  61.     //------------------------------------------------------------------------------------
  62.     // Procedural View Creation
  63.     //------------------------------------------------------------------------------------
  64.  
  65.     virtual TWindow* NewPaletteWindow(ResNumber itsRsrcID,
  66.                                      Boolean wantHScrollBar,
  67.                                      Boolean wantVScrollBar,
  68.                                      TDocument* itsDocument,
  69.                                      TView* itsMainView,
  70.                                      TView* itsPaletteView,
  71.                                      short sizePalette,
  72.                                      VHSelect whichWay);
  73.         // Used for creating MacDraw-like windows with 1 non-scrolling palette along the
  74.         // left edge (whichWay = h), or a non-scrolling status area at the top of the window
  75.         // (whichWay = v), and a main view that may or may not scroll. Signals Failure if the
  76.         // window could not be created.
  77.     
  78.     virtual TWindow* NewSimpleWindow(ResNumber itsRsrcID,
  79.                                     Boolean wantHScrollBar,
  80.                                     Boolean wantVScrollBar,
  81.                                     TDocument* itsDocument,
  82.                                     TView* itsView);
  83.         // Used for creating simple windows that contain 1 view and may or may not scroll.
  84.         // Signals Failure if the window could not be created.
  85.     
  86.     virtual void AddSubViewWithScroller(TWindow* aWindow,
  87.                                                 TView* itsView,
  88.                                                 Boolean wantHScrollBar,
  89.                                                 Boolean wantVScrollBar,
  90.                                                 const VPoint& itsLocation);
  91.         // Used to add a view to a window, creating a scroller if needed.
  92.  
  93.     virtual TWindow* NewTWindow(ResNumber itsRsrcID, TDocument* itsDocument);
  94.         // Used for creating a window object. Used within NewPaletteWindow &
  95.         // NewSimpleWindow. SIgnals Failure if the window could not be created.
  96.     
  97.     //------------------------------------------------------------------------------------
  98.     // Creating Views from View Template
  99.     //------------------------------------------------------------------------------------
  100.  
  101.     virtual TWindow* NewTemplateWindow(ResNumber viewRsrcID, TDocument* itsDocument);
  102.         // Used for creating a window using a 'view' template.
  103.  
  104.     virtual TView* DoCreateViews(TDocument* itsDocument,
  105.                                         TView* parentView,
  106.                                         ResNumber itsRsrcID,
  107.                                         const VPoint& subViewOffset);
  108.         // Creates the view hierarchy using ReadViewsFromResource, and calls the root view's
  109.         // AdjustSize and HandlePostCreate methods
  110.  
  111.     virtual TView* ReadViewsFromResource(TDocument* itsDocument,
  112.                                               TView* parentView,
  113.                                               ResNumber itsRsrcID,
  114.                                               const VPoint& subViewOffset);
  115.         // This is the method responsible for creating view hierarchies from resource
  116.         // templates. 
  117.     
  118.     // ??? should we have a ReadViewsFromHandle
  119.  
  120.     virtual TView* ReadViewsFrom(TStream* itsStream,
  121.                                         TView* parentView,
  122.                                         const VPoint& subviewOffset);
  123.         // Called from ReadViewsFromResource
  124.     
  125.     //------------------------------------------------------------------------------------
  126.     // Writing Views
  127.     //------------------------------------------------------------------------------------
  128.  
  129.     virtual void WriteViewsToResource(TView* view,
  130.                                              ResNumber itsRsrcID,
  131.                                              const CStr255& name,
  132.                                              short resourceAttributes);
  133.         // Calls WriteViewsToHandle to write the view to a handle, and adds the handle to
  134.         // the current resource fork as a 'View' resource with the given resource id, name,
  135.         // and resource attributes.
  136.  
  137.     virtual Handle WriteViewsToHandle(TView* view);
  138.         // Creates a stream and calls WriteViewsTo to write out the view to the stream.
  139.         // Returns the handle containing the streamed views, suitable for saving as a resource.
  140.  
  141.     //------------------------------------------------------------------------------------
  142.     // View Stream Management
  143.     //------------------------------------------------------------------------------------
  144.  
  145.     virtual TStream* DoMakeViewStream(ResNumber itsRsrcID, Handle itsHandle);
  146.         // creates and returns a TStream to be used when reading or writing views
  147.         // if itsHandle != NULL, uses this to create the handle
  148.         // else if itsRsrcID != kNoResourceID, uses this to retrieve the resource
  149. };
  150.  
  151.  
  152. // --------------------------------------------------------------------------------------------------
  153. extern TViewServer* gViewServer;                // the globally accessible view server
  154.  
  155.  
  156. #endif // __UVIEWSERVER__
  157.